﻿using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace FitnessClubManager
{
    class Helper
    {
        public static void SaveImageAvatar(System.Drawing.Image image, string tenFile)
        {
            try
            {
                if (!Directory.Exists("D:\\fitnessapp\\avatar"))
                    Directory.CreateDirectory("D:\\fitnessapp\\avatar");
                string filePathAvatarTemp = "D:\\fitnessapp\\avatar\\" + tenFile + ".jpg";
                if (File.Exists(filePathAvatarTemp))
                    File.Delete(filePathAvatarTemp);
                image.Save(filePathAvatarTemp);
            }
            catch
            {
                throw new Exception("Thêm avatar thất bại");
            }
        }
        public static void SaveImageAvatar(string filePath, string newTenFile)
        {
            try
            {
                if (!Directory.Exists("D:\\fitnessapp\\avatar"))
                    Directory.CreateDirectory("D:\\fitnessapp\\avatar");
                string filePathAvatarTemp = "D:\\fitnessapp\\avatar\\" + newTenFile + ".jpg";
                if (File.Exists(filePathAvatarTemp))
                    File.Delete(filePathAvatarTemp);
                File.Copy(filePath, filePathAvatarTemp);
            }
            catch
            {
                throw new Exception("Thêm avatar thất bại");
            }
        }
    }
}
